<?php 
class Application_Model_DbTable_Comments extends Zend_Db_Table_Abstract{
    protected $_name = "comments";
    protected $_primary = "comment_id";
    
    public function add($data){
        return $this->createRow($data)->save();
    }
    
    public function edit($data){
        $row = $this->find($data['comment_id'])->current();
        if($row){
            $row->setFromArray($data);
            return $row->save();
        }
        return false;
    }
    
    public function convertObjectToArray($object){
        $res = array();
        foreach($object as $key => $val){
            $res[$key] = $val;
        }
        return $res;
    }
    
    public function convertField(&$data){
        $data['commentId'] = $data['comment_id'];
        $data['userId'] = $data['user_id'];
        $data['eventId'] = $data['event_id'];
        $data['content'] = $data['content'];
        $data['date'] = $data['date'];
    }
    
    public function convertField2(&$data){
        $data['comment_id'] = $data['commentId']; 
         $data['user_id'] = $data['userId'];
        $data['event_id'] = $data['eventId'];
        $data['content'] = $data['content'];
        $data['date'] = $data['date'];
    }
    
}